//
//  HMHTTPManager.h
//  HuanMai
//
//  Created by Magician on 2018/3/20.
//  Copyright © 2018年 LinkWheat. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "YGURLDefines.h"

#define kDefultErrorMsg @"网络似乎不可用"

typedef void(^CNRequestSuccessBlock)(id responeObj);
typedef void(^CNPageRequestSuccessBlock)(NSArray *dataArray, NSInteger pageId);
typedef void(^CNRequestFailureBlock)(NSError *error,NSString *errorDes);

@interface CNHTTPManager : NSObject

@property (nonatomic ,strong) AFHTTPSessionManager *sessionManager;

/** 当前请求operation对象 */
@property (nonatomic ,strong) NSOperationQueue *operationQueue;


+ (instancetype)shared;

/**
 POST网络请求
 
 @param URLString 接口路径
 @param parameters 接口参数
 @param success 成功回调
 @param failure 失败回调
 */
- (void)POST:(NSString *)URLString
  parameters:(NSDictionary *)parameters
     success:(CNRequestSuccessBlock)success
     failure:(CNRequestFailureBlock)failure;

/**
 GET网络请求
 
 @param URLString 接口路径
 @param parameters 接口参数
 @param success 成功回调
 @param failure 失败回调
 */
- (void)GET:(NSString *)URLString
 parameters:(NSDictionary *)parameters
    success:(CNRequestSuccessBlock)success
    failure:(CNRequestFailureBlock)failure;

/**
 *取消当前请求队列的所有请求
 */
- (void)cancelAllOperations;

/**
 监听网络状态,网络状态
 */
+ (void)listenNetworkStatus:(void(^)(AFNetworkReachabilityStatus status))networkStatus;

@end


@interface CNResponseDataModel : NSObject

@property (nonatomic, strong) NSString *status;
@property (nonatomic, strong) NSString *message;
@property (nonatomic, strong) id data;

@end
